package com.example.administrator.android2019.ch2Activity;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.ImageView;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.Toast;

import com.example.administrator.android2019.R;

public class GoddnessActivity extends AppCompatActivity {

   private ImageView image_beauty;
    private RadioButton rb,liu;
    private RadioGroup radio_beauty;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_goddness);

        init();
        RadioGroup.OnCheckedChangeListener check=new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
               switch (checkedId){
                   case R.id.rb:
                       image_beauty.setImageResource(R.drawable.di);
                       Toast.makeText(GoddnessActivity.this, "热巴+1", Toast.LENGTH_SHORT).show();
                       break;
                   case R.id.liu:
                       image_beauty.setImageResource(R.drawable.liu);
                       Toast.makeText(GoddnessActivity.this, "刘亦菲+1", Toast.LENGTH_SHORT).show();
                       break;
               }
            }
        };
        radio_beauty.setOnCheckedChangeListener(check);
    }
    private void init(){
        image_beauty=findViewById(R.id.image_beauty);
        rb=findViewById(R.id.rb);
        liu=findViewById(R.id.liu);
        radio_beauty=findViewById(R.id.radio_beauty);
        image_beauty.setImageResource(R.drawable.di);
        rb.setChecked(true);
    }
}
